# Copyright 2024 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

package(
    default_visibility = ["//visibility:public"],
    licenses = ["notice"],
)

cc_library(
    name = "packet_listener",
    testonly = 1,
    srcs = ["packet_listener.cc"],
    hdrs = ["packet_listener.h"],
    deps = [
        ":p4rt_programming_context",
        "//gutil/gutil:testing",
        "//p4_pdpi:ir_cc_proto",
        "//p4_pdpi:p4_runtime_session",
        "//p4_pdpi:pd",
        "//sai_p4/instantiations/google:instantiations",
        "//sai_p4/instantiations/google:sai_p4info_cc",
        "//sai_p4/instantiations/google:sai_pd_cc_proto",
        "//thinkit:control_device",
        "//thinkit:packet_generation_finalizer",
        "//thinkit:switch",
        "@com_github_google_glog//:glog",
        "@com_github_p4lang_p4runtime//:p4runtime_cc_proto",
        "@com_google_absl//absl/base:core_headers",
        "@com_google_absl//absl/container:flat_hash_map",
        "@com_google_absl//absl/status",
        "@com_google_absl//absl/strings",
    ],
)

cc_library(
    name = "p4rt_programming_context",
    srcs = ["p4rt_programming_context.cc"],
    hdrs = ["p4rt_programming_context.h"],
    deps = [
        "//p4_pdpi:p4_runtime_session",
        "@com_github_google_glog//:glog",
        "@com_github_p4lang_p4runtime//:p4runtime_cc_proto",
        "@com_google_absl//absl/functional:bind_front",
        "@com_google_absl//absl/status",
    ],
)

cc_test(
    name = "p4rt_programming_context_test",
    srcs = ["p4rt_programming_context_test.cc"],
    deps = [
        ":p4rt_programming_context",
        "//gutil/gutil:proto_matchers",
        "//gutil/gutil:status_matchers",
        "//gutil/gutil:testing",
        "//p4_pdpi:p4_runtime_session",
        "@com_github_p4lang_p4runtime//:p4runtime_cc_proto",
        "@com_google_absl//absl/status",
        "@com_google_googletest//:gtest_main",
    ],
)

cc_library(
    name = "p4rt_port",
    srcs = ["p4rt_port.cc"],
    hdrs = ["p4rt_port.h"],
    deps = [
        "//gutil/gutil:status",
        "//p4_pdpi/string_encodings:byte_string",
        "//p4_pdpi/string_encodings:decimal_string",
	"//p4_pdpi/string_encodings:hex_string",
        "@com_google_absl//absl/numeric:bits",
        "@com_google_absl//absl/status",
        "@com_google_absl//absl/status:statusor",
        "@com_google_absl//absl/strings",
        "@com_google_absl//absl/strings:str_format",
        "@com_google_absl//absl/types:span",
    ],
)

cc_test(
    name = "p4rt_port_test",
    srcs = ["p4rt_port_test.cc"],
    deps = [
        ":p4rt_port",
        "//gutil/gutil:status_matchers",
        "@com_google_absl//absl/status",
        "@com_google_absl//absl/strings:string_view",
        "@com_google_googletest//:gtest_main",
    ],
)
